﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="content_list.aspx.cs" Inherits="TRPOP.CMS.Web.Admin.content_list" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>内容管理-<%=base.m_strBaseAdminPageName%></title>
    <script src="../../js/utils.js" type="text/javascript"></script>
    <script src="../../js/jquery.js" type="text/javascript"></script>
    <script src="../js/jquery.form.js" type="text/javascript"></script>
    <script src="../tree/xmenu.js" type="text/javascript"></script>
    <link href="../tree/xmenu.css" rel="stylesheet" type="text/css" />
    <script src="../js/content_list.js" type="text/javascript"></script>
</head>
<body>
    <form id="form1" runat="server">
    <script runat="server" type="text/C#">
        #region 可以根据具体情况定做页面显示方式
        /// <summary>
        /// 获取浏览的html
        /// </summary>
        /// <param name="strContentId"></param>
        /// <param name="strUrl"></param>
        /// <returns></returns>
        public string GetView(string strContentId, string strUrl)
        {
            return "<a id=\"URL_" + strContentId + "\"  href=\"" + strUrl + "\"onclick=\"window.open(this.href);return false;\"  >浏览<a>";
        }
        /// <summary>
        /// 获取发布的html
        /// </summary>
        /// <param name="strContentId"></param>
        /// <param name="strUrl"></param>
        /// <returns></returns>
        public string GetPub(string strContentId, string strNodeId)
        {
            return "<a href=\"admin_publish.aspx?ac=PubContent&contentid=" + strContentId + "&nodeid=" + strNodeId + "\">发布</a>";
        }
        /// <summary>
        /// 是否是UnPublish
        /// </summary>
        /// <param name="oType"></param>
        /// <returns></returns>
        public bool IsUnPublish(object oPubStatus)
        {
            return Convert.ToInt32(oPubStatus) == (int)TRPOP.Common.PubStatus.EnumElement.UnPublish;
        }
        /// <summary>
        /// 是否是NotOutPub
        /// </summary>
        /// <param name="oType"></param>
        /// <returns></returns>
        public bool IsNotOutPub(TRPOP.CMS.Model.NodeInfo oNodeInfo)
        {
            return oNodeInfo.ContentPubTypeId == (int)TRPOP.Common.ContentPubType.EnumElement.NotOutPub;
        }
        /// <summary>
        /// 编辑
        /// </summary>
        /// <param name="strContentId"></param>
        /// <returns></returns>
        public string GetEdit(string strContentId)
        {
            return "  <a href=\"javascript:void(0);\" onclick=\"javascript:doing('editdoc'," + strContentId + ");\"> 编辑</a>";
        }
        /// <summary>
        /// 获取评论
        /// </summary>
        /// <param name="strContentId"></param>
        /// <returns></returns>
        public string GetRec(string strContentId)
        {
            if (TRPOP.CMS.Model.SYSConfig.RecommentConfigerInfo.Enable)
                return " <a  href=\"../recomment/recomment_list.aspx?id=" + strContentId + "\">评论</a>";
            else
                return "";
        }
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="strContentId"></param>
        /// <returns></returns>
        public string GetUpadte(string strContentId)
        {
            //return " <a href=\"admin_publish.aspx?ac=RePubContent&contentid= " + strContentId + "\" onclick=\"doing('RePubContent', '" + strContentId + "')\" >更新</a> ";
            return " <a href=\"#\" onclick=\"doing('RePubContent', '" + strContentId + "')\" >更新</a> ";
        }
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="strContentId"></param>
        /// <returns></returns>
        public string GetDelete(string strContentId)
        {
            return " <a href=\"javascript:void(0);\" onclick=\"doing('del'," + strContentId + ")\">删除</a> ";
        }
        /// <summary>
        /// 获取信息类型
        /// </summary>
        /// <param name="objType"></param>
        /// <returns></returns>
        public TRPOP.Common.LinkType.EnumElement GetLinkType(object objType)
        {
            if (Convert.ToInt32(objType) == (int)TRPOP.Common.LinkType.EnumElement.RealLink)
                return TRPOP.Common.LinkType.EnumElement.RealLink;
            if (Convert.ToInt32(objType) == (int)TRPOP.Common.LinkType.EnumElement.VirtualLink)
                return TRPOP.Common.LinkType.EnumElement.VirtualLink;
            if (Convert.ToInt32(objType) == (int)TRPOP.Common.LinkType.EnumElement.OutLink)
                return TRPOP.Common.LinkType.EnumElement.OutLink;
            if (Convert.ToInt32(objType) == (int)TRPOP.Common.LinkType.EnumElement.IndexLink)
                return TRPOP.Common.LinkType.EnumElement.IndexLink;
            return TRPOP.Common.LinkType.EnumElement.RealLink;
        }
        /// <summary>
        /// 获取信息类型
        /// </summary>
        /// <param name="objType"></param>
        /// <returns></returns>
        public string GetLinkTypeString(object objType)
        {
            if (Convert.ToInt32(objType) == (int)TRPOP.Common.LinkType.EnumElement.RealLink)
                return "实链接";
            if (Convert.ToInt32(objType) == (int)TRPOP.Common.LinkType.EnumElement.VirtualLink)
                return "虚链接";
            if (Convert.ToInt32(objType) == (int)TRPOP.Common.LinkType.EnumElement.OutLink)
                return "外链接";
            if (Convert.ToInt32(objType) == (int)TRPOP.Common.LinkType.EnumElement.IndexLink)
                return "索引链接";
            return "实链接";
        }

        public string getOperString(TRPOP.CMS.Model.NodeInfo oNodeInfo, object objType, object objPubStatus, object objContentId, object objUrl, object objNodeID)
        {
            StringBuilder strBuilder = new StringBuilder();
            string strSpace = "&nbsp;";
            bool blnIsNotOutPub = IsNotOutPub(oNodeInfo);//是否 不对外发布
            bool blnIsUnPublish = IsUnPublish(objPubStatus);//是否 未发布
            if (blnIsNotOutPub == false)//对外发布  
            {
                if (blnIsUnPublish)//未发布
                {
                    strBuilder.Append(GetPub(objContentId.ToString(), objNodeID.ToString()) + strSpace);//发布
                }
                else//已发布
                {
                    strBuilder.Append(GetView(objContentId.ToString(), objUrl.ToString()) + strSpace);//浏览
                }
            }
            switch (GetLinkType(objType))
            {
                case TRPOP.Common.LinkType.EnumElement.IndexLink://索引链接
                    //索引链接：只有 发布/浏览  删除 
                    break;
                case TRPOP.Common.LinkType.EnumElement.OutLink://外链接
                    if (TRPOP.CMS.Model.SYSConfig.RecommentConfigerInfo.Enable)
                        strBuilder.Append(GetRec(objContentId.ToString()) + strSpace);//评论
                    strBuilder.Append(GetEdit(objContentId.ToString()) + strSpace);//编辑
                    break;
                case TRPOP.Common.LinkType.EnumElement.RealLink://实链接
                    if ((blnIsNotOutPub == false) && (blnIsUnPublish == false))//不对外发布 并且 已发布
                    {
                        strBuilder.Append(GetUpadte(objContentId.ToString()) + strSpace);//更新 
                    }
                    if (TRPOP.CMS.Model.SYSConfig.RecommentConfigerInfo.Enable)
                        strBuilder.Append(GetRec(objContentId.ToString()) + strSpace);//评论
                    strBuilder.Append(GetEdit(objContentId.ToString()) + strSpace);//编辑
                    break;
                case TRPOP.Common.LinkType.EnumElement.VirtualLink://虚连接
                    if (blnIsUnPublish == false && blnIsNotOutPub == false)//已发布 并且 对外发布
                    {
                        strBuilder.Append(GetUpadte(objContentId.ToString()) + strSpace);//更新 
                    }
                    break;
            }
            strBuilder.Append(GetDelete(objContentId.ToString()) + strSpace);//删除
            return strBuilder.ToString();
        }
        public string GetItemList(System.Data.DataRowView oTempDataRowView, bool blnFieldListDisplay, bool blnIsTitleField, string strFieldName)
        {
            string strTheme = TRPOP.CMS.Model.SystemInfoHelper.getSystemInfo().CMSThemes;
            if (blnFieldListDisplay == false)//如果标题不列表显示
                return "";
            if (blnIsTitleField == false)//如果不是标题字段
                return oTempDataRowView.Row[strFieldName].ToString();
            //如果是标题字段
            StringBuilder strBuilder = new StringBuilder();
            if (Convert.ToInt32(oTempDataRowView.Row["TopWeight"]) > 0)//置顶显示
            {
                strBuilder.Append("[" + dataRowView.Row["TopWeight"] + "]&nbsp;<img src=\"../../App_Themes/" + strTheme + "/images/top.gif\"   alt=\"置顶\" title=\"置顶\" align=\"middle\" border=\"0\" />");
            }
            if (Convert.ToInt32(dataRowView.Row["EliteWeight"]) > 0) //精华显示
            {
                strBuilder.Append("[" + dataRowView.Row["EliteWeight"] + "]&nbsp;<img src=\"../../App_Themes/" + strTheme + "/images/pink.gif\" alt=\"精华\" title=\"精华\" align=\"middle\" border=\"0\" />");
            }
            strBuilder.Append("<a   href=\"javascript:void(0);\" onclick=\"doing('view','" + dataRowView.Row["ContentId"] + "')\" ");//标题单击设置
            strBuilder.Append("     oncontextmenu=\"rightMenu('" + dataRowView.Row["ContentId"] + "', '" + dataRowView.Row["PubStatus"] + "','" + dataRowView.Row["Type"] + "','" + dataRowView.Row["TopWeight"] + "','" + dataRowView.Row["EliteWeight"] + "','0',event);return false;\" ");//标题右键设置
            strBuilder.Append("     > ");
            strBuilder.Append("  <span  title=\"小贴示:点右键有更多操作\"  class=\"linktype" + dataRowView.Row["Type"] + "\">" + TRPOP.Common.StringExtension.CutStringWithByte(dataRowView.Row[Eval("FieldName").ToString()].ToString(), TRPOP.CMS.Model.SYSConfig.SystemVar_ListTitleLength));/*标题的类型样式和显示长度*/
            strBuilder.Append("  </span>");
            strBuilder.Append("</a>");
            if (dataRowView.DataView.Table.Columns["Photo"] != null && dataRowView.Row["Photo"].ToString() != "")//信息图片字段的判断 
                strBuilder.Append("<span style=\"  padding-left:15px;\"><img alt=\"新闻图片\" title=\"新闻图片\" src=\"../../App_Themes/" + strTheme + "/images/image.gif\"/></span>");
            return strBuilder.ToString();
        }
        #endregion
    </script>
    <!--导航-->
    <table id="page_navigator">
        <tr>
            <td class="align_l">
                当前位置：发布管理 -> 内容管理
            </td>
            <td class="align_r">
                <span class="Red">注：</span>文章按照“发布状态->置顶->发布日期->文章排序权重”的优先顺序进行排序
            </td>
        </tr>
    </table>
    <!--菜单-->
    <div id="menudata">
    </div>
    <!--列表-->
    <table class="table_search" cellpadding="0" cellspacing="2" width="100%" border="0">
        <tr>
            <td nowrap="nowrap" width="50">
                &nbsp;&nbsp;显示:
            </td>
            <td nowrap="nowrap" width="150">
                <asp:DropDownList runat="server" ID="ddlPublishStatus" />
            </td>
            <td align="right" nowrap="nowrap" width="150">
                按发布日期查询:
            </td>
            <td align="left" nowrap="nowrap" width="200">
                <cms:TextBox runat="server" ID="txtPubTime" onclick="javascript:return new Calendar.display(this.id,event);"
                    Width="100px" />
                <input name="Go" class="button_style" type="button" value="执行" onclick="doing('date_search')" />
            </td>
            <td align="right" nowrap="nowrap" width="150">
                关键字查询:
            </td>
            <td nowrap="nowrap" width="250">
                <input type="text" name="SearchKeywords" runat="server" id="SearchKeywords" value=""
                    class="txtBlur" onfocus='this.className="control_focus"' onblur='this.className="control_blur"' />
                <input name="Go" class="button_style" type="button" value="执行" onclick="doing('keyword_search')" />
            </td>
            <td>
                &nbsp;
            </td>
        </tr>
    </table>
    <!--列表-->
    <table class="table_list">
        <tbody>
            <tr>
                <th>
                </th>
                <th>
                    ID
                </th>
                <th>
                    排序
                </th>
                <cms:Repeater runat="server" ID="repTitleList">
                    <ItemTemplate>
                        <th>
                            <%#Eval("Name") %>
                        </th>
                    </ItemTemplate>
                </cms:Repeater>
                <th>
                    编辑
                </th>
                <th>
                    发布日期
                </th>
                <th>
                    发布状态
                </th>
                <th>
                    操作
                </th>
                <th>
                    <a title="【实】：实链接指向的是一个结点中实实在在的内容记录。&#10;&#10;【虚】：虚链接是实链接的一个指针，让一篇文章归属多个结点。&#10;&#10;【索】：索引链接主要用于专题管理，建立一个专题文章。&#10;&#10;【外】：外链接是链接到站外的一个地址。"
                        href="javascript:void(0);">类型</a>
                </th>
            </tr>
            <cms:Repeater ID="rptList" runat="server" OnItemDataBound="rptList_ItemDataBound">
                <ItemTemplate>
                    <tr>
                        <td>
                            <input type="checkbox" name="delid" value="<%# Eval("ContentId")%>" />
                        </td>
                        <td>
                            <span style="width: 100%">
                                <%# Eval("ContentId")%></span>
                        </td>
                        <td>
                            <%# Eval("DisplayOrder")%>
                        </td>
                        <cms:Repeater ID="rptFieldList" runat="server">
                            <ItemTemplate>
                                <td>
                                    <%#GetItemList(dataRowView,Convert.ToBoolean(Eval("FieldListDisplay")),Convert.ToBoolean(Eval("IsTitleField")),Eval("FieldName").ToString())%>
                                </td>
                            </ItemTemplate>
                        </cms:Repeater>
                        <td>
                            <%#GetAdminNameById(Convert.ToInt32(Eval("AddUserId")))%>
                        </td>
                        <td>
                            <%# Eval("PubTime")%>
                        </td>
                        <td>
                            <%# Convert.ToInt32(Eval("PubStatus")) == (int)TRPOP.Common.PubStatus.EnumElement.UnPublish ? 
                                TRPOP.Common.PubStatus.GetValue(Convert.ToInt32(Eval("PubStatus")))
                                : 
                                 "<span class=\"Red\">" + TRPOP.Common.PubStatus.GetValue(Convert.ToInt32(Eval("PubStatus"))) + " </span>" %>
                        </td>
                        <td>
                            <%#getOperString(m_NodeInfo, Eval("Type"), Eval("PubStatus"),  Eval("ContentId"),Eval("Url"), Eval("NodeId") )%>
                        </td>
                        <td>
                            <%#"<span   class=\"linktype" + Eval("Type").ToString() + "\">" + GetLinkTypeString( Eval("Type")) + "</span>"%>
                        </td>
                    </tr>
                </ItemTemplate>
            </cms:Repeater>
        </tbody>
    </table>
    <!--操作-->
    <table class="table_operator">
        <tr class="tr_operator">
            <th class="align_l">
                <input type="checkbox" name="chkall" value="on" onclick="setCheckAll(this)" id="chkall" />
                <label for="chkall">
                    全选</label>&nbsp;&nbsp;
                <select name="actionMap" id="actionMap">
                    <%if (m_NodeInfo != null)
                      {%>
                    <%if (m_NodeInfo.ContentPubTypeId == (int)TRPOP.Common.ContentPubType.EnumElement.StaticPub)
                      { %>
                    <option value="RePubContent">更新</option>
                    <%}%>
                    <%if (m_NodeInfo.ContentPubTypeId != (int)TRPOP.Common.ContentPubType.EnumElement.NotOutPub)
                      { %>
                    <option value="PubContent">发布</option>
                    <option value="unpublish">取消发布</option>
                    <!--option value="tempUnPublish">临时取消发布</option-->
                    <%} %>
                    <option value="copy">复制</option>
                    <option value="cut">转移</option>
                    <option value="top">批量置顶</option>
                    <option value="pink">批量精华</option>
                    <option value="del">删除</option>
                    <option value="destroy">永久删除</option>
                    <option value="createLink">创建虚链接</option>
                    <option value="createIndexLink">创建索引链接</option>
                    <%if (m_NodeInfo.ContentPubTypeId != (int)TRPOP.Common.ContentPubType.EnumElement.NotOutPub)
                      { %>
                    <option value="all_unpublish">结点-全部取消发布</option>
                    <option value="all_tempUnpublish">结点-全部临时取消发布</option>
                    <option value="all_republish">结点-全部重新发布</option>
                    <%} %>
                    <%}%>
                </select>
                <input type="button" value="执行" class="button_style" onclick="going();" />
            </th>
            <th class="align_l">
                设置发布时间 :
                <cms:TextBox runat="server" ID="txtDate" onclick="javascript:return new Calendar.display(this.id,event);"
                    Width="100px" />
                <cms:DropDownList runat="server" ID="ddlHour" />
                时
                <cms:DropDownList runat="server" ID="ddlMinute" />
                分
                <cms:DropDownList runat="server" ID="ddlSecond" />
                秒
                <input type="button" id="btplan" class="button_style" value="执行" onclick="doing('plan')" />
            </th>
            <th class="align_r">
                <input type="button" value="显示" class="button_style" onclick="doing('offset',0);" />
                <input type="text" size="7" value="15" id="offset" name="offset" />
                条记录
            </th>
        </tr>
        <tr class="tr_pager">
            <td colspan="3">
                <cms:PagerGet ID="Pager" runat="server" />
            </td>
        </tr>
    </table>
    </form>
    <script language="javascript" type="text/javascript">
        $(document).ready(function() {
                bind();
                $("#offset").val(<%=Pager.PageSize%>);
        });
    </script>
</body>
</html>
